import backtrader as bt
import pandas as pd
import datetime
from ImSS import SSAverange


if __name__ == '__main__':
    cerebro = bt.Cerebro()

    dataframe = pd.read_csv('data/bitmex.csv')
    dataframe['open_time'] = pd.to_datetime(dataframe['open_time'])
    dataframe.set_index('open_time', inplace=True)
    brf_ = bt.feeds.PandasData(
        dataname=dataframe,
        fromdate=datetime.datetime(2019,10,15,0,0,0),
        todate=datetime.datetime(2019,10,16,0,0,0),
        timeframe=bt.TimeFrame.Minutes
    )
    cerebro.adddata(brf_)
    cerebro.addstrategy(SSAverange)
    cerebro.broker.setcommission(commission=0.002)
    cerebro.addsizer(bt.sizers.FixedSize, stake=10)
    cerebro.run()
    # cerebro.plot()
